package ArithmeticSelf;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        //定义数组--------------------
        int[] array1 = new int[10];
        int m = 0;
        for (int i=0;i<array1.length;i++) {
            array1[i] = (int)(Math.random()*100)+1;
            System.out.print(array1[i]+"\t");
            m++;
            if (m%5==0) {
                System.out.println();
            }
        }

        //冒泡排序----------------------
        int temp;
        for (int i=1;i<array1.length;i++) {
            for (int j=0;j<array1.length-i;j++) {
                if (array1[j]>array1[j+1]) {
                    temp =array1[j];
                    array1[j] = array1[j+1];
                    array1[j+1] = temp;
                }
//                System.out.println("第"+i+"回，第"+j+"次排序："+ Arrays.toString(array1));
            }
            System.out.println("第"+i+"回排序："+Arrays.toString(array1));

        }
        System.out.println(Arrays.toString(array1));
    }
}
